﻿// Overlays are floating visual elements that can be used to implement tooltips, masks, dialogs and any other type of popup
define([
    'Wjs/ui/widgets/foundation/ViewSingleContainer',
    'Wjs/ui/elements/managers/zIndexManager',
    'Wjs/ui/widgets/body'
],
function () {
    'use strict';

    var zIndexManager = Wjs.getType('zIndexManager');

    return Wjs.defineOnce({

        type: 'Overlay',

        internal: {

            base: Wjs.getType('ViewSingleContainer'),

            initialize: function () {

                this.setParent(Wjs.getType('body')); // The default parent of the overlay is the HTML body element

                this.addClass('wjs-overlay');

                this.hide(); // Initially hidden
            }
        },

        showHandler: function () {

            zIndexManager.add(this);
        },

        hideHandler: function () {

            zIndexManager.remove(this);
        }
    });

});